import http from '@/utils/request.js'

/* Equipment - 查询设备信息
 */
export function getEquipmentMsg(id) {

	return http.BaseRequest({
		url: "/equipment_user/"+id,
		method: 'get'
	})
}

/* Problem user - 查询常见问题列表
文章列表获取时，通过设备类型判断，只获取更该设备类型相关的维护教程
 */

export function getProblemList(type,limit,page) {

	return http.BaseRequest({
		url: `/problem_user?type=${type}&title=&limit=${limit}&page=${page}`,
		method: 'get'
	})
}


/* Problem user - 读取常见问题
 */
export function getProblemContent(id) {

	return http.BaseRequest({
		url: "/problem_user/"+id,
		method: 'get'
	})
}

// /**
//  * repair user 查看报修列表
//  */
// export function getRepairList(id,limit,page) {

// 	return http.BaseRequest({
// 		url: `/repair_user?equipment_id=${id}&limit=${limit}&page=${page}`,
// 		method: 'get'
// 	})
// }


/* 查询工程师信息 */
export function getEngineerserById(id) {

	return http.BaseRequest({
		url: "/engineer_user/" + id,
		method: 'get'

	})
}

/* repair user 查看报修单 */

export function getMaintenance(id) {

	return http.BaseRequest({
		url: "/repair_user/" + id,
		method: 'get'

	})
}

/* repair user 创建报修  */
/* 
phonenumber: '', //手机号
username: '', //姓名
areadesc: '', // 报修内容 
verify: '' //输入的验证码 
*/


export function createRepair(info) {

	return http.BaseRequest({
		url: "/repair_user?action=createRepair&phone=" + info.phonenumber +
				"&equipment_id=" + info.equipment_id + 
				"&applicant=" + info.username + 
				"&content=" + info.areadesc +
				"&user_code=" + info.user_code +
				"&file[]="+info.file[0]+
				"&file[]="+info.file[1]+
				"&file[]="+info.file[2]+
				"&file[]="+info.file[3]+
				"&file[]="+info.file[4]
				,
				
		method: 'post'

	})
}

/* repair user 发送验证码 */
export function sendCode(phone) {
	
	return http.BaseRequest({
		url: "/repair_user?action=sendCode&phone="+phone,
		method: 'post'

	})
}

/*repair user 校验验证码 */
export function verifyCode(code,user_code) {

	return http.BaseRequest({
		url: "/repair_user?action=checkCode&code="+code+"&user_code="+user_code,
		method: 'post'

	})
}

/* 查询常见问题列表 */

export function getIssuesList() {

	return http.BaseRequest({
		url: "/problem_user",
		method: 'get'

	})
}
/* 读取常见问题 */
export function getReadIssuesList(id) {

	return http.BaseRequest({
		url: "/problem_user/" + id,
		method: 'get'

	})
}

/* evaluate user 创建评价(type=1评价，type=0投诉) */

export function createAdvise(info) {

	return http.BaseRequest({
		url: "/evaluate_user?action=createEvaluate&user_phone=" + info.phonenumber +
				"&repair_id=" + info.repair_id + 
				"&user=" + info.username + 
				"&content=" + info.areadesc +
				"&equipment_id=" + info.equipment_id +
				"&user_code=" + info.user_code +
				"&type=" +info.type+
				"&file[]="+info.file[0]+
				"&file[]="+info.file[1]+
				"&file[]="+info.file[2]+
				"&file[]="+info.file[3]+
				"&file[]="+info.file[4],
				
		method: 'post'

	})
}

/* Evaluate user - 发送验证码
 */
export function sendEvaluateCode(phone) {

	return http.BaseRequest({
		url: "/evaluate_user?action=sendCode&user_phone="+phone,
		method: 'post'
	
	})
}

/* Evaluate user - 效验验证码
 */
export function verifyEvaluateCode(code,user_code) {

	return http.BaseRequest({
		url: "/evaluate_user?action=checkCode&code="+code+"&user_code="+user_code,
		method: 'post'

	})
}
/*  */